package com.open.common.enums;

import java.util.Arrays;

/**
 * 配置枚举
 *
 * @author dashu03
 * @date 2025-04-08 15:55:55
 */
public enum ConfigEnum {
    /**
     * 系统配置
     */
    Index(1, "Index", "首页提示语"),
    CheckCode(1, "CheckCode", "是否开启验证码"),
    Register(1, "Register", "是否开启注册功能"),
    IPBlack(1, "IPBlack", "黑名单配置"),
    ThemeColor(1, "ThemeColor", "系统主题颜色"),
    SideColor(1, "SideColor", "侧边栏颜色"),

    /**
     * 用户配置
     */
    DataBase(2, "DataBase", "数据库配置"),
    Generate(2, "Generate", "代码生成器配置");

    // 配置状态（1.系统配置， 2.用户配置）
    public Integer status;
    // 配置类型
    public String type;
    // 配置名称
    public String name;

    ConfigEnum(Integer status, String type, String name) {
        this.status = status;
        this.type = type;
        this.name = name;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static ConfigEnum match(String type, Integer status) {
        return Arrays.stream(ConfigEnum.values())
                .filter(configEnum -> configEnum.getType().equals(type) && configEnum.getStatus().equals(status))
                .findFirst()
                .orElse(null);
    }
}
